<?php

namespace App\Http\Middleware;

use Closure;

class CorsMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        //指定允许其他域名访问
        header('Access-Control-Allow-Origin:*');
        // 响应类型
        header('Access-Control-Allow-Methods:POST, GET, OPTIONS, PUT, DELETE');
        header('Access-Control-Allow-Headers:Content-Type, X-Auth-Token, Origin');
        // 响应头设置
        header('Access-Control-Allow-Headers:x-requested-with,content-type');
        return $next($request);

    }
}
